package xyz.syyrjx.blog.scheduling;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import xyz.syyrjx.blog.service.SiteSubmitService;

import javax.annotation.Resource;


/**
 * @author 大地崩坏苍蝇兽
 * @date 2024/2/20 20:27
 * @description 定时任务：每天两点把未同步的url同步到百度
 * @since v0.0.1
 */
@Component
public class SynchronizeURLToBaidu {
    private final Logger logger = LoggerFactory.getLogger(SynchronizeURLToBaidu.class);

    @Resource
    SiteSubmitService siteSubmitService;

    @Scheduled(cron ="0 0 2 * * ?")
    public void doTask(){
        try {
            String information = siteSubmitService.submitService("baidu");
            logger.info("定时任务执行成功，执行结果：{}",information);
        } catch (Exception e) {
            logger.error("定时任务执行出错{}", e.toString());
        }
    }
}
